<?php
namespace Home\Controller;
use Think\Controller;
class Interface2Controller extends Controller {
    public function updatePayment(){//万年历支付订单回调 手动
//        $providerArr=S('providerArr');
//        if(empty($providerArr)){
//            $providerArr=M()->query("select providerCode from provider where userinfo=123");
//            S('providerArr',$providerArr,3600);
//        }
        $providerArr=array(
            array('providerCode'=>'hx_huawei',),
        );
        foreach($providerArr as $key=>$value){
            $channel=$value['providerCode'];
            $h5Arr=M()->query("select ordernum,price,typeid,createtime,appuserid,channel from sm_h5test where channel='{$channel}' and status=1 and createtime>='2020-04-11 00:00:00'");
            foreach($h5Arr as $key=>$value){
                $post=array(
                    'imei'=>$value['appuserid'],
                    'orderdate'=>mb_substr($value['createtime'],0,10),
                    'channel'=>$value['channel'],
                    'gold'=>$value['price'],
                    'typeid'=>$value['typeid'],
                    'ordernum'=>$value['ordernum'],
                );
                if($value['appuserid']){
                    //$curl="http://119.23.205.117:8085/wnl/apitest/updatePayment?imei={$post['imei']}&orderdate={$post['orderdate']}&channel={$post['channel']}&gold={$post['gold']}&typeid={$post['typeid']}&ordernum={$post['ordernum']}";
                    $curl="http://wnlendaradmin.fangzhou-sh.net/ZxNews/apitest/updatePayment?imei={$post['imei']}&orderdate={$post['orderdate']}&channel={$post['channel']}&gold={$post['gold']}&typeid={$post['typeid']}&ordernum={$post['ordernum']}";
                    $json=curlGet($curl);
                    echo $json;
                }
            }
        }
    }
    public function updatePayOrderid($ordernum=null){//万年历支付通知回调
        $Arr=S('sm_h5test|'.$ordernum);
        $channel=$Arr['channel'];
        $providerArr=S('providerArr');
        if(empty($providerArr)){
            $providerArr=M()->query("select providerCode from provider where userinfo=123");
            S('providerArr',$providerArr,3600);
        }
        foreach($providerArr as $key=>$value){
            if($value['providerCode']==$channel){
                $typeData=1;break;
            }
        }
        if($typeData==1){
            $post=array(
                'imei'=>$Arr['appuserid'],
                'orderdate'=>mb_substr($Arr['createtime'],0,10),
                'channel'=>$Arr['channel'],
                'gold'=>$Arr['price'],
                'typeid'=>$Arr['typeid'],
                'ordernum'=>$Arr['ordernum'],
            );
            $curl="http://119.23.205.117:8085/wnl/apitest/updatePayment?imei={$post['imei']}&orderdate={$post['orderdate']}&channel={$post['channel']}&gold={$post['gold']}&typeid={$post['typeid']}&ordernum={$post['ordernum']}";
            //file_put_contents("./Upload/updatePayOrderid{$ordernum}.txt",$curl);
            $json=curlGet($curl);
        }
    }
    public function BBsurnameData(){//姓氏数据
        $surname=$_REQUEST['surname'];
        $url="http://baziqmwang.qiming100.cn/name/GetXingQiyuan?xs={$surname}";

        $strData=S('surnameQiyuan'.$surname);
        if(empty($strData)){
            $json=curlGet($url);
            $json=json_decode($json,true);
            $strData=$json['qiyuan'];
            $qiyuanArr=M()->query("select id from tb_bb_qiyuan where surname='{$surname}'");
            if(empty($qiyuanArr)){M()->query("insert into tb_bb_qiyuan (surname,qiyuan)values('{$surname}','{$strData}')");}
            S('surnameQiyuan'.$surname,$strData,36000);
        }

        $arr=array(
            'text'=>$strData
        );
        echo json_encode($arr,JSON_UNESCAPED_UNICODE);
    }
    public function BBmakeUserInsert(){//预约信息记录
        $uid=$_REQUEST['uid'];
        $sexName=$_REQUEST['sexName'];
        $surname=$_REQUEST['surname'];
        $phone=$_REQUEST['phone'];
        $birthday=$_REQUEST['birthday'];//0-2018-08-08-08
        $makeCode=$_REQUEST['makeCode'];

        judgeData(array($uid,$sexName),$_REQUEST);

        $userArr=M()->query("select id from tb_bb_user_makecoke where uid='{$uid}' and sex_name='{$sexName}' and surname='{$surname}' and birthday='{$birthday}' and make_code='{$makeCode}' and phone='{$phone}'");

        if(empty($userArr)){
            M()->query("insert into tb_bb_user_makecoke (uid,sex_name,surname,birthday,make_code,phone)values('{$uid}','{$sexName}','{$surname}','{$birthday}','{$makeCode}','{$phone}')");
            $arr=array('code'=>1,'content'=>'预约记录成功',);
        }else{
            $arr=array('code'=>2,'content'=>'预约记录重复',);
        }
        echo json_encode($arr,JSON_UNESCAPED_UNICODE);
    }
    public function data_qm_lxmc(){//流行名称
    }
}